<?php
/*
 * Created on 08.04.2007
 * @filesource: schichtplan.php
 * @author: Nikolai Plath
 */

   defined( '_VALID_MOS' ) or die( 'Direct Access to this
      script is not allowed');
   $query = 'SELECT * FROM #__schichtplan '
            .'WHERE published="1"';
   $database->setQuery( $query );
   $rows = $database->loadObjectList();
   echo '<div align="center">' .
   		'<table width="98%" border="1">' .
   		'<tr bgcolor="#FFFFCC"><th colspan="8">Sendeplan</th></tr>';
   	echo '<tr align="center" bgcolor="#FFFFCC">' .
   		'<td>&nbsp;</td><td>Montag</td><td>Dienstag</td><td>Mittwoch</td><td>Donnerstag</td><td>Freitag</td><td>Samstag</td><td>Sonntag</td>';
   foreach($rows as $row)
  {
     echo '<tr align="center">' .
     		'<td bgcolor="#FFFFCC">' . $row->uhrzeit . '</td>' .
      '<td align="center">'. getdjname($row->mo).'</td>
       <td align="center">'. getdjname($row->di).'</td>
       <td align="center">'. getdjname($row->mi).'</td>
       <td align="center">'. getdjname($row->do).'</td>
       <td align="center">'. getdjname($row->fr).'</td>
       <td align="center">'. getdjname($row->sa).'</td>
       <td align="center">'. getdjname($row->so).'</td>
     </tr>';
  }
  echo '</table></div>';
function getdjname ($djid)
{
	global $database;
	if ($djid == '0')
	{
		return "Non Stop";
	}
	$database->setQuery("SELECT * from #__comprofiler".
			"\n WHERE user_id='".$djid."'");
	$database->loadObject($cbuser);
	
	
	$return = '';
	
	$cbprofillink = '<a href="index.php?option=com_comprofiler&amp;task=userProfile&amp;user=' . $cbuser->user_id . '">' . $cbuser->cb_djname . '</a>';
	if (strpos($cbuser->avatar, "/") === false )
	{	//custom userpic
		$cbPicPath='images/comprofiler/tn';
	} else
	{	//userpic from gallery
		$cbPicPath = 'components/com_comprofiler/images/';
	}

	if ($cbuser->avatar == '')
	{	//user has NO avatar
		$return .= $cbprofillink;//$cbuser->cb_djname;

//		$TabEinsContent = "<strong>" . $user->firstname . " " . $user->lastname . "</strong>";
	} else
	{
	$cbprofilavatarlink = '<a href="index.php?option=com_comprofiler&amp;task=userProfile&amp;user=' . $cbuser->user_id . '"><img src="'.$cbPicPath.$cbuser->avatar.'" alt="Image" /></a><br />';

		$return .= $cbprofilavatarlink.$cbprofillink;//"<img src='".$cbPicPath.$cbuser->avatar."' alt='Image' /><br />"
//		.$cbprofillink;
//		.$cbuser->cb_djname;
//		."</strong>";
	}

	
	
	
	
	
	
	
	
	
	return $return;
}
?>
